package com.xuelang.pipeline.worker.client.common.feign;

import com.xuelang.pipeline.worker.client.common.result.ApiResult;
import com.xuelang.pipeline.worker.client.pod.IPodService;
import com.xuelang.pipeline.worker.client.pod.dto.PodQueryDTO;
import com.xuelang.pipeline.worker.client.pod.dto.QueryDTO;
import io.kubernetes.client.openapi.models.V1PodList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;

import jakarta.validation.Valid;

/**
 * Pod服务fegin调用失败回调实现类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@Component
public class PodServiceFallbackImpl implements IPodService {
    private final String fallReason = "服务降级：远程服务不可用";
    private final ApiResult apiResult = ApiResult.fail("worker返回异常：" + fallReason);
    @Override
    public ApiResult<V1PodList> getPodList(QueryDTO podListRequest) { return ApiResult.<V1PodList>failT(fallReason); }
    @Override
    public ApiResult<String> getPodLog(PodQueryDTO podLogRequest) { return ApiResult.<String>failT(fallReason); }
    @Override
    public ResponseEntity<StreamingResponseBody> streamPodLog(@Valid PodQueryDTO queryDTO) { return null; }
}
